<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>simple Imitate</title>
    <style>
        .bigBox{
            width: 400px;
            height: 50px;
        }
        .bigBox #box {
            width: 200px;
            height: 50px;
            font-size: 25px;
            color: aqua;
            cursor: pointer;
            float: left;
        }
        .bigBox span{
            display: block;
            width: 120px;
            height: 50px;
            font-size: 25px;
            color: skyblue;
            cursor: pointer;
            float: left;
        }
        .secondBox{
            width: 400px;
            height: 120px;
        }
        .secondBox span{
            display: block;
            width: 120px;
            height: 50px;
            font-size: 25px;
            color: skyblue;
            cursor: pointer;
            float: left;
        }

        .secondBox #box1{
            width: 200px;
            height: 33px;
            font-size: 25px;
            color: aqua;
            float: left;
            border: 1px solid #d1d1d1;
            outline: none;
        }
    </style>
</head>
<body>
<div class="bigBox">
    <span>输入回显</span>
    <div id="box">你好，世界！</div>
</div>
<div class="secondBox">
    <span>输入</span><label>
    <input id="box1" type="text" name="text">
</label>
</div>
<script>
    function init(value) {
        var obj = {}
        let obox = document.getElementById("box");
        Object.defineProperty(obj, "myname", {
            get() {
                console.log("get");
                return obox.innerHTML = value;
            },
            set(value) {
                console.log(value);
                obox.innerHTML = value;
            }
        });
        obj.myname = value
    }
    function RePlaceHander() {
        var value = document.getElementById("box1").value;
        init(value);
    }
    function RePlace() {
        document.getElementById("box1").addEventListener("input", RePlaceHander);
    }
    RePlace();
</script>
</body>
</html>